﻿@model OrderControllerModel.Index
<div class="my-main">
    <div class="ui-box  ui-box-alpha">
        <div class="ui-box-head">
            <div class="ui-box-head-border">
                <div class="ui-box-head-title">
                    订单中心</div>
                <span class="ui-box-head-text">@(Order.CategoryDic.FirstOrDefault(o => o.Key == Model.Category).Value)</span>
                @if (Model.Category == OrderCategory.Normal)
                {
                    <a href="#" class="ui-box-head-more">去购物</a>
                }
                else if (Model.Category == OrderCategory.Auction)
                {
                    <a href="#" class="ui-box-head-more">去竞购</a>
                }
                else
                {
                    <a href="#" class="ui-box-head-more">去玩游戏</a>
                }
            </div>
        </div>
        <div class="ui-box-container">
            <div class="ui-box-content">
                dd</div>
        </div>
        <div class="ui-box-container-noborder">
            <div class="ui-box-content">
            </div>
        </div>
        <div class="ui-box-container-noborder">
            <div class="tabbable">
                <ul class="nav nav-tabs" style="padding-left: 40px;">
                    <li class="@(Model.Category == OrderCategory.Normal ? "active" : string.Empty)"><a
                        href="/order">网购订单</a></li>
                    <li class="@(Model.Category == OrderCategory.Auction ? "active" : string.Empty)"><a
                        href="/order?category=1">竞购订单</a></li>
                    <li class="@(Model.Category == OrderCategory.GameRecharge ? "active" : string.Empty)"><a
                        href="/order?category=2">游戏充值订单</a></li>
                </ul>
                <div class="tab-content">
                    <div class="tab-pane active">
                        @if (Model.Category == OrderCategory.GameRecharge)
                        {
                            @GameOrder.GetHtml(Model.Orders)
                        }
                        else
                        {
                            <table class="ui-table ui-table-inbox ui-table-alpha">
                                <thead>
                                    <tr>
                                        <th style="width: 250px;">
                                            商品信息
                                        </th>
                                        <th>
                                            单价(元)
                                        </th>
                                        <th>
                                            数 量
                                        </th>
                                        <th>
                                            售 后
                                        </th>
                                        <th>
                                            实付款(元)
                                        </th>
                                        <th>
                                            订单状态
                                        </th>
                                        <th>
                                            操 作
                                        </th>
                                    </tr>
                                </thead>
                                @Model.Orders.Each(@<tbody class="@(item.Item.Status == OrderStatus.Pending ? "item-pending" : "item")">
                                    <tr class="item-header">
                                        <td colspan="7" class="text-align-left">
                                            <div class="row">
                                                <div class="col-md-1">
                                                    <label class="checkbox-inline"><input type="checkbox" value="@(item.Item.Id)"/>&nbsp;</label></div>
                                                <div class="col-md-4">
                                                    订单编号：@(item.Item.Id)</div>
                                                <div class="col-md-3">
                                                    成交时间：@(item.Item.CreatedOn.ToString("yyyy-MM-dd HH:mm:ss"))</div>
                                                <div class="col-md-3">@(item.Item.BuyerNick)</div>
                                                <div class="col-md-1">
                                                    <a href="javascript:void(0);" class="pull-right" data-rel="popover" data-toggle="popover"
                                                                            data-trigger="hover" data-container='body' data-placement="left" data-title="备 忘" data-content="@(item.Item.BuyerMemo.IsNullOrEmpty() ? "暂时没有备忘信息！" : item.Item.BuyerMemo)">
                                                        <i class="icon-flag" style="color: red;"></i></a>
                                                </div>
                                            </div>
                                        </td>
                                    </tr>
                                    @for (var i = 0; i < item.Item.OrderItems.Count; i++)
                                    {
                                        var temp = item.Item.OrderItems[i];
                                        <tr @(i < item.Item.OrderItems.Count - 1 ? "class=light" : string.Empty)>
                                            <td class="col  @(item.Item.OrderItems.Count > 1 ? "multiple light" : string.Empty)">
                                                <div class="media">
                                                    <a class="pull-left" href="" target="_blank">
                                                        <img data-src="holder.js/64x64" class="media-object" alt="64x64" style="width: 64px;
                                                            height: 64px;" src="">
                                                    </a>
                                                    <div class="media-body">
                                                        <h5 class="media-heading">
                                                            @(temp.Title)
                                                        </h5>
                                                        <p>
                                                            @foreach (var o in temp.GetProperties().OrderBy(o => o.Length))
                                                            {
                                                                @(o)<br />
                                                            }
                                                        </p>
                                                    </div>
                                                </div>
                                            </td>
                                            <td class="col @(item.Item.OrderItems.Count > 1 ? "multiple light" : string.Empty)">
                                                @(temp.Price.ToString("N"))
                                            </td>
                                            <td class="col @(item.Item.OrderItems.Count > 1 ? "multiple light" : string.Empty)">
                                                @(temp.Quantity)
                                            </td>
                                            <td class="col @(item.Item.OrderItems.Count > 1 ? "light" : string.Empty)">
                                                @if (temp.Status == OrderStatus.WaitSellerSend || temp.Status == OrderStatus.SellerSendPart || temp.Status == OrderStatus.WaitBuyerConfirm)
                                                {
                                                    if (!temp.RefundId.IsNullOrEmpty() && temp.RefundStatus.HasValue)
                                                    {
                                                    <p>
                                                        <a href="/refund/detail/@temp.RefundId">退款处理中</a></p>
                                                    }
                                                    else
                                                    {
                                                    <p>
                                                        <a href="/refund/apply/@temp.Id" target="_blank">退款/退货</a></p>
                                                    }
                                                }
                                            </td>
                                            @if (i == 0)
                                            {
                                                <td class="col" @(item.Item.OrderItems.Count > 1 ? "rowspan=" + (item.Item.OrderItems.Count) : string.Empty)>
                                                    <p>
                                                        <strong>@(item.Item.Total.ToString("N"))</strong></p>
                                                    @if (item.Item.Postage == 0)
                                                    {
                                                        <p>
                                                            <span>免运费</span></p>
                                                    }
                                                    else
                                                    {
                                                        <p>
                                                            <span>含快递：@(item.Item.Postage.ToString("N"))</span></p>
                                                    }
                                                    <p>
                                                        <span>订单优惠：@(item.Item.Discount.ToString("N"))</span></p>
                                                </td>
                                                <td class="col" @(item.Item.OrderItems.Count > 1 ? "rowspan=" + (item.Item.OrderItems.Count) : string.Empty)>
                                                    @if (item.Item.Status == OrderStatus.Pending || item.Item.Status == OrderStatus.WaitBuyerPay)
                                                    {
                                                        <a class="order-status" href="/order/detail/@(item.Item.Id)" target="_blank">待付款</a>

                                                    }

                                                    else if (item.Item.Status == OrderStatus.WaitSellerSend)
                                                    {
                                                        <p>
                                                            <a class="order-status" href="/order/detail/@(item.Item.Id)" target="_blank">已付款待发货</a>
                                                        </p>
                                                        <p>
                                                            <a>提醒商家发货</a></p>
                                                    }
                                                    else if (item.Item.Status == OrderStatus.SellerSendPart)
                                                    {
                                                        <p>
                                                            <a class="order-status" href="/order/detail/@(item.Item.Id)" target="_blank">部分发货</a>
                                                        </p>
                                                        <p>
                                                            <a>提醒商家发货</a></p>
                                                    }
                                                    else if (item.Item.Status == OrderStatus.WaitBuyerConfirm)
                                                    {
                                                        <a class="order-status" href="/order/detail/@(item.Item.Id)" target="_blank">已发货待确认</a>
                                                    }
                                                    else if (item.Item.Status == OrderStatus.Canceled)
                                                    {
                                                        <a class="order-status" href="/order/detail/@(item.Item.Id)" target="_blank">交易关闭</a>
                                                    }
                                                    else if (item.Item.Status == OrderStatus.Finished)
                                                    {
                                                        <a class="order-status" href="/order/detail/@(item.Item.Id)" target="_blank">交易成功</a>
                                                    }
                                                </td>
                                                <td class="ui-table-action" @(item.Item.OrderItems.Count > 1 ? "rowspan=" + (item.Item.OrderItems.Count) : string.Empty)>
                                                    @if (item.Item.Status == OrderStatus.Pending || item.Item.Status == OrderStatus.WaitBuyerPay)
                                                    {
                                                        if (item.Item.Status == OrderStatus.Pending)
                                                        {
                                                        <p>
                                                            <a href="/order/pay/@(item.Item.Id)" target="_blank" class="btn btn-danger">付 款</a></p>
                                                        }
                                                        else
                                                        {
                                                        <p>
                                                            <a href="@WebSite.Pay/order/?param=@(item.Item.Id)" target="_blank" class="btn btn-danger">
                                                                付 款</a></p>
                                                        }
                                                        <p>
                                                            <a data-trigger="modal" href="/order/cancel/@(item.Item.Id)" data-title="取消订单">取消订单</a></p>
                                                    }
                                                    else if (item.Item.Status == OrderStatus.WaitBuyerPay)
                                                    {
                                                        <a class="order-status" href="@(WebSite.Pay)/order/?param=@(item.Item.Id)" target="_blank">
                                                            付 款</a>
                                                    }
                                                    else if (item.Item.Status == OrderStatus.WaitBuyerPay)
                                                    {
                                                        <a href="@(WebSite.Pay)/order?param=@(item.Item.Id)"  target="_blank">付款</a>
                                                    }
                                                    <p>
                                                        <a data-trigger="modal" href="/order/memo/@(temp.OrderId)"
                                                                                data-title="备忘">备 忘</a>
                                                    </p>
                                                </td>
                                            }
                                        </tr>

                                    }
                                    <tr class="item-footer">
                                        <td colspan="7">
                                        </td>
                                    </tr>
                                </tbody>)
                            </table>
                        }
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@section js{
    <script type="text/javascript">
        $(function () { //Sk.Passport.Fun.validateLogin(window);
            $('[data-rel="popover"]').popover();
        });
    </script>
}
